package com.example.cggame;

import java.io.IOException;

import android.media.MediaPlayer;
import android.os.Handler;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.Log;
import android.view.*;

public class GameThread extends Thread {

	/** Handle to the surface manager object we interact with */
	private SurfaceHolder surfaceHolder;
	private Paint paint;
	private GameState state;
	MediaPlayer music;
	

	public GameThread(SurfaceHolder surfaceHolder, Context context, Handler handler)
	{
		this.surfaceHolder = surfaceHolder;
		paint = new Paint();
		state = new GameState();
	}

	@Override
	public void run() {
		while(true)
		{
			Canvas canvas = surfaceHolder.lockCanvas();
			state.update();
			state.draw(canvas,paint);
			surfaceHolder.unlockCanvasAndPost(canvas);
		}
	}

	public GameState getGameState()
	{
		return state;
	}
}